#include "logo.h"

void load(void)
{
     FILE *f;
     int i;
     int l;
     int j;
     int k;
     int parL;
     char *name;
     char nameStr[MAXVALUE];

     name =nameStr;
     strcpy(name,getValue());
     if ((f =fopen(name,"r+")) == NULL)
     {
        printf("CAN'T OPEN FILE\n");
        return ;
     }
     fgets(name,255,f);
     name[strlen(name)-1]='\0';
     l =atoi(name);
     printf("file word number is %d\n",l);
     for (i=0;i<l;i++)
     {
         fgets(name,255,f);
         name[strlen(name)-1]='\0';
         printf("file word name is %s\n",name);
         for (j=0;j<wordLen;j++)
         {
             if (!strcmp(name,wordName[j]))
             {
                fgets(name,255,f);
                name[strlen(name)-1]='\0';
                strcpy(wordValue[j],name);
                printf("file word value is %s\n",name);
                goto JUMP;
             }
         }
         wordLen++;
         strcpy(wordName[wordLen-1],name);
         fgets(name,255,f);
         name[strlen(name)-1]='\0';
         strcpy(wordValue[wordLen-1],name);
         printf("file word name is %s\n",name);
         JUMP:
              continue;
     }
     fgets(name,255,f);
     name[strlen(name)-1]='\0';
     l =atoi(name);
     for (i=0;i<l;i++)
     {
         fgets(name,255,f);
         name[strlen(name)-1]='\0';
         printf("to name is %s.\n",name);
         for (j=0;j<toLen;j++)
         {
             if (!strcmp(name,toName[j][0]))
             {
                fgets(name,255,f);
                name[strlen(name)-1]='\0';
                parL=atoi(name);
                toPar[j] =parL;
                for (k=1;k<=parL;k++)
                {
                    fgets(name,255,f);
                    name[strlen(name)-1]='\0';
                    strcpy(toName[j][k],name);
                }
                goto JUMP2;
             }
         }
         toLen++;
         strcpy(toName[toLen-1][0],name);
         fgets(name,255,f);
         name[strlen(name)-1]='\0';
         parL=atoi(name);
         toPar[toLen-1] =parL;
         fgets(name,255,f);
         name[strlen(name)-1]='\0';
         strcpy(toValue[toLen-1][0],name);
         for (k=1;k<=parL;k++)
         {
             fgets(name,255,f);
             name[strlen(name)-1]='\0';
             strcpy(toName[toLen-1][k],name);
         }
         JUMP2:
              continue;
     }

     fclose(f);
     return ;
}
